package hard数组中位数;

import org.testng.annotations.Test;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Solution {
    public double findMedianSortedArrays(int[] nums1, int[] nums2) {
        List<Integer> list = new ArrayList<>();

        for (int i:
                nums1) {
            list.add(i);
        }

        for (int i:
                nums2) {
            list.add(i);
        }
        Collections.sort(list);
        return list.size()%2==0 ? (double)(list.get((int)list.size()/2)+list.get((int)list.size()/2-1))/2:list.get((int)list.size()/2);
    }

    @Test
    public void test(){
        int[] a = {1,2};
        int[] b = {3,4};
        System.out.println(findMedianSortedArrays(a,b));
    }
}
